<#-- Finds entity with given name -->
<#function findEntity entityName>
  <#foreach classMapping in cfg.classMappings>
    <#if classMapping.entityName?split(".")?last?matches(entityName)>
      <#return classMapping/>
    </#if>
  </#foreach>
  <#return 0/>
</#function>

<#-- Function that determines whether given 'Entity' has a View'Entity'Picker entity -->
<#function hasPickerEntity entityName>
  <#assign pickerViewName = "View"+entityName?cap_first+"Picker"/>
  <#foreach classMapping in cfg.classMappings>
    <#if classMapping.entityName?split(".")?last?matches(pickerViewName)>
      <#return true/>
    </#if>
  </#foreach>
  <#return false/>
</#function>

<#-- Function that determines whether entity with given name is a picker entity ('View'<Entity>'Picker'<Suffix>) -->
<#function isPickerEntity entityName>
  <#return entityName?trim?lower_case?matches("view.*picker.*")/>
</#function>

<#-- Returns identifier property name for entity of given name  -->
<#function getPickerIdentifierName entityName>
  <#if isPickerEntity(entityName)>
    <#assign tmpName = entityName?replace("View", "")?replace("Picker.*", "", 'r')/>
    <#return findEntity(entityName).identifierProperty.name + "." + findEntity(tmpName).identifierProperty.name/>
  </#if>
  <#return findEntity(entityName).identifierProperty.name/>
</#function>

<#-- Returns display property name for entity of given name  -->
<#function getPickerDisplayName entityName>
  <#if isPickerEntity(entityName)>
    <#return "${'$'}{i.id.pickerDisplay}">
  </#if>
  <#return "NOT_PICKER_ENTITY"/>
</#function>

<#-- Returns picker name for given entity -->
<#function getPickerName entityName>
  <#assign pickerViewName = "View"+entityName?cap_first+"Picker"/>
  <#foreach classMapping in cfg.classMappings>
    <#if classMapping.entityName?split(".")?last?matches(pickerViewName)>
      <#return pickerViewName/>
    </#if>
  </#foreach>
  <#return entityName/>
</#function>

<#-- Determines which properties of given entity should be omitted in the output -->
<#function getOmittedPropertyNames entityName>
  <#if isPickerEntity(entityName)>
    <#return [getPickerIdentifierName(entityName)]/>
  </#if>
  <#return []/>
</#function>

<#function isPropertyOmitted prop omittedList>

</#function>
